use chrono::{DateTime,Utc};
use sha2::{Sha256,Digest};
use hex::encode;
pub enum PlatformType {
    Directly=0,
    OAuth=1
}
declare_dao!(PlatformDao {
    id:i64,
    name:String,
    access_key:Option<String>,
    secure_key:Option<String>,
    api_root:Option<String>,
    r#type:i32,
    description:Option<String>,
    created_at:DateTime<Utc>,
    updated_at:DateTime<Utc>
};"platforms";i64;id);

impl PlatformDao {
    pub fn password_digest(password:&str)->String {
        let mut hasher = Sha256::new();
        hasher.update(password);
        hasher.update(":platforms");
        encode( hasher.finalize())
    }
}